
function xy(a_x, a_y) {
	this.x = a_x;
	this.y = a_y;
};


//arrX,arrY are set by York at creation
// This is the place that the tile is in the array of the level data
//
//x,y are set by York at creation
// This is based off of the arrX and arrY
// They are the location of the center of the tile on the map itself
//
//drawID is received from the graphics engine
// This is the current texture it uses when drawing
//
//type is set by York at creation
// This contains the information it needs to send to the graphcis engine to
// get the proper drawID.
//
//next is an xy object set at map creation
// This value can be a single x,y coordinate, or an array of up to 3 x,y
// coordinates. All the logic for this is done in this function and the only 
// interactions creeps need to have with the path is to call its current
// destinations getNext() function when it reaches the same x,y.
//
//getNext() returns an xy object containing the x,y of the next location that the creep should be
// moving towards
function PathTile(a_arrX,a_arrY,a_x,a_y,a_drawID,a_type,a_next) {
	this.arrX = a_arrX;
	this.arrY = a_arrY;
	this.x = a_x;
	this.y = a_y;
	this.drawID = a_drawID;
	this.type = a_type;
	this.next = [];
	if(a_next != null)
		this.next = a_next.slice();
	this.compass = 0;
	this.addNext = function (a_next) {
		this.next[this.next.length] = a_next;
	}
	this.getNext = function (a_prev){
		if(this.type == "End") return null;
		switch(this.next.length) {
		case 1:
			return this.next[0];
		case 2:
			if(a_prev == null)
				return this.next[0];
			else if(a_prev == this.next[0])
				return this.next[1];
			else return this.next[0];
		case 3:
			if(this.entryPoint != a_prev) {
				this.entryPoint = a_prev;
				this.compass = 0;
			}
			else if(a_prev == null) {
				this.compass += 1;
				if(this.next[this.compass] == null)
					this.compass = 0;
				return this.next[this.compass];
			}
			if(this.next[this.compass] == null)
				this.compass = 0;
				
			this.compass += 1;
			
			if(this.next[this.compass].x == this.entryPoint.x &&
				this.next[this.compass].y == this.entryPoint.y)
				this.compass += 1;
				
			if(this.next[this.compass] == null)
				this.compass = 0;

			return this.next[this.compass];
			
		}
		/*
		if(this == null || this.type != "End") {
			//if(this.next[this.compass + 1] != null)
			//	this.compass += 1;
			//else this.compass = 0;
			if(a_prev != this.next[this.compass]) {
				if(a_prev == null)
					drawList.drawText(0,150,150);
				return this.next[this.compass];
			}
			else {
				if(this.compass+1 < this.next.length) {
					drawList.drawText(2,150,150);
					return this.next[this.compass+1];
				}
				else {
					drawList.drawText(3,150,150);
					return this.next[0];
				}
			}
		}*/
		return null;
	}
}